package com.jiashihui.server1.test.callback;

/**
 * @author jiashihui
 * @describe: TODO
 * @date 2019/02/18
 */
public class XiaoLi {
    protected EatRice er;

    public void setEatRiceListener(EatRice er, String food) {
        this.er = er;
        washFace(food);
    }

    public void washFace(String food) {
        System.out.println("小李要洗漱");
        new Thread(() -> {
            try {
                //小李洗漱的同时小明玩手机，开启线程实现异步
                play();
                Thread.sleep(10000);
                System.out.print("10秒后 ");
                //B调用A的方法
                er.eat(food);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }

    //小明玩手机
    private void play() {
        System.out.println("----小明要玩手机----");
    }
}
